home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4524 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  61 lines

  1. Path: yarrow.wt.com.au!not-for-mail
  2. From: brendanl@wt.com.au (Brendan Langoulant)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Message port
  5. Date: 29 Feb 1996 19:32:31 GMT
  6. Organization: Winthrop Technology
  7. Message-ID: <4h4v0f$esk@yarrow.wt.com.au>
  8. References: <708.6632T987T2426@academy.bastad.se>
  9. NNTP-Posting-Host: sage
  10. X-Newsreader: TIN [UNIX 1.3 950520BETA PL0]
  11.  
  12. Sten Jansson (sten@academy.bastad.se) wrote:
  13. : I've tried to create a message-port in a simple test-program. It works,
  14. : ,but as soon as I start another program the message-port disappear.
  15. : Here is my program:
  16. : --
  17. : void AddportT(struct MsgPort * MP)
  18. : {
  19. :  int SIGBIT;
  20. :  if((SIGBIT=AllocSignal(-1L))==-1)
  21. :    exit(0);
  22. :  MP=  AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC|MEMF_CLEAR);
  23.  
  24. You pass a message port to this routine, but it is discarded at this 
  25. point before it is ever used.  The value of this message port will not be 
  26. passed back either as you are only modifying a copy of the pointer.
  27.  
  28. : Please help me if You know what's wrong! Maybe I should use some
  29. : special compiler directives?
  30.  
  31. Try this pair of calls, they do everything you want.
  32.  
  33. struct MsgPort *CreatePort( STRPTR name, long pri );
  34. void DeletePort( struct MsgPort *ioReq );
  35.  
  36. eg.
  37.  
  38. main()
  39. {
  40.    struct MsgPort *port;
  41.  
  42.    /* Attempt to allocate a port */
  43.    if ( port = CreatePort( "PortName", -125 ) )
  44.    {
  45.       
  46.       /* Clean up Message Port */
  47.       DeletePort( port );
  48.    }
  49.    else
  50.    {
  51.       /* Failed to allocate a port */
  52.    }
  53. }
  54.  
  55. --
  56. Brendan Langoulant
  57. Software Author
  58. brendanl@mail.wt.com.au
  59.